<div class="title">
	<h3>标签管理</h3>
	<ul>
		<li <?php if($_GET['type']!=1):?>class="current"<?php endif;?>><a href="?r=tags" title="标签管理">标签管理</a></li>
		<li <?php if($_GET['type']==1):?>class="current"<?php endif;?>><a href="?r=tags/index&type=1" title="排斥标签">排斥标签</a></li>
	</ul>
</div>
<div class="main_content">
	<div class="label_set">
		<div id='mytags' class="existing_label"> <strong><?php if($_GET['type']!=1):?>现有标签：<?php else:?>排斥标签<?php endif;?></strong>
		<?php if(count($rs)>0):?>
		<?php foreach($rs as $v):?>
			<span  tag="<?php echo $v[id];?>"><?php echo CHtml::encode($v[tag_name]);?></span>
		<?php endforeach;?>
		<?php else:?>
			<span>您还未设置标签</span>
		<?php endif;?>
		</div>
		<?php $form = $this->beginWidget('CActiveForm',array(
		'id'=>'add_tags',
		)); ?>

		<div class="add_label form"> <strong><?php echo $form->labelEx($model, 'taglist')?></strong>
		<?php echo $form->textField($model,'taglist');?>
		<span class="add_but" onclick="$('#add_tags').submit();">添加</span>
        <div class="clear"></div> 
		<p style="padding-left:75px;"><?php echo $form->error($model, 'taglist');?></p>
        <style type="text/css">
         .errorMessage{ padding-left:75px;}
		</style>
		</div>
		<?php $this->endWidget(); ?>
		<?php if($_GET['type']!=1):?>
			<div class="hot_label">
				<h2>热门标签：</h2>
				<p>
				<?php foreach((array)$hot_tags as $v):?>
				<span class='fav_t' tag="<?php echo $v[0];?>" st="<?php echo $v[1];?>"><?php echo $v[1];?>, </span>
				<?php endforeach;?>
				</p>
				
				<p>（单击添加）</p>
			</div>
			<div class="recommend_label">
				<h2>推荐标签：</h2>
				<?php $cnams = Tags::className(); foreach((array)$forword_tags as $k=>$v):?>
				<p><strong><?php echo $cnams[$k];?>：</strong>
					<?php foreach((array)$v as $vs):?>
				<span class='fav_t' tag="<?php echo $vs[0];?>" st="<?php echo $vs[1];?>"><?php echo $vs[1];?>, </span>
					<?php endforeach;?>
				</p>
				<?php endforeach;?>
				
			</div>
		<?php endif;?>
		</div>
	</div>
<script type="text/javascript">

var msg = "<?php echo $msg['status'];?>";
if(msg!=0){
	$('#topmsg').html("<?php echo $msg['desc']; ?>");
    $('#showmsg').show();
    showDialog();
    setTimeout(function(){location.reload();},400);

}
$(document).ready(function(){
	$('.fav_t').click(function(){
		  var ids = $(this).attr('tag');
		  var st =$(this).attr('st');
			$.post('?r=tags/add',{id:ids},
				function(data){
					data = $.parseJSON(data);
					if(data.status=='0'){
						var tmp="<span tag='"+ids+"'>"+st+"</span>";
						$('#mytags').append(tmp);

					}
					else alert(data.desc);
				});
	})
})
</script>
